import {defineStore} from 'pinia'
import {nextTick} from "vue";

const useAppStore = defineStore({
    id: 'app',
    state: () => {
        return {
            isMobile: true,
            isCollapsed: false,
            isRouteShow: true,
        }
    },
    actions: {
        setMobile(value) {
            this.isMobile = value
        },
        toggleCollapsed(toggle) {
            this.isCollapsed = toggle ?? !this.isCollapsed
        },
        refresh() {
            this.isRouteShow = false;
            nextTick(() => {
                this.isRouteShow = true
            })
        }
    }
})

export default useAppStore